class Solution:
    def pivotIndex(self, nums: list[int]) -> int:
        n = len(nums)
        sum = 0
        jisuan = 0
        for i in range(0, n):
            sum = sum + nums[i]
        for j in range(0, n):
            if jisuan * 2 + nums[j] == sum:
                return j
            jisuan += nums[j]
        return -1

sol = Solution()

nums = [-1,-1,0,1,1,0]

print(sol.pivotIndex(nums))

           

# class Solution:
#     def pivotIndex(self, nums: list[int]) -> int:
#         sum = 0
#         for i in range(len(nums)):
#             sum += nums[i]
#         curr_sum = 0
#         for i in range(len(nums)):
#             if curr_sum * 2 + nums[i] == sum:
#                 return i
#             curr_sum += nums[i]
#         return -1
    

# sol = Solution()

# nums = [-1,-1,0,1,1,0]

# sol.pivotIndex(nums)